<template>
    <div>
        <div class="top">
            <img src="../../assets/img/cg.png" alt="" style="width: 60px;height: 60px;">
            <h1 style="width: 400px;">采购需求填报</h1>
            <div class="top_one">
            </div>
        </div>
        <div style="display: flex; align-items: center; margin-top: 20px">
            <div style="margin-left: 30px">相关项目:</div>
            <div style="margin-left: 10px">
                <el-input prefix-icon="el-icon-search" v-model="input1"> </el-input>
            </div>
            <div style="margin-left: 30px">发起部门:</div>
            <div style="margin-left: 10px">
                <el-input prefix-icon="el-icon-search" v-model="input2"> </el-input>
            </div>
            <div style="margin-left: 30px">物品名称:</div>
            <div style="margin-left: 10px">
                <el-input prefix-icon="el-icon-search" v-model="input3"> </el-input>
            </div>
            <div style="margin-left: 50px">
                <el-button type="primary" @click="queryData">查询</el-button>
            </div>
            <div style="margin-left: 50px">
                <el-button type="primary" @click="resetData">重置</el-button>
            </div>
        </div>
        <div>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column prop="number" label="需求编号"> </el-table-column>
                <el-table-column prop="relatedTo" label="相关项目"> </el-table-column>
                <el-table-column prop="creationTime" label="创建时间"> </el-table-column>
                <el-table-column prop="initiatingDepartment" label="发起部门"> </el-table-column>
                <el-table-column prop="filler" label="填报人"> </el-table-column>
                <el-table-column prop="fillingTime" label="填报时间"> </el-table-column>
                <el-table-column prop="itemName" label="物品名称"> </el-table-column>
                <el-table-column prop="requiredQuantity" label="需求数量"> </el-table-column>
                <el-table-column prop="expectedArrivalTime" label="期望到货时间"> </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page.sync="currentPage2" :page-sizes="[10, 20, 30, 40]" :page-size="10"
                layout="sizes, prev, pager, next" :total="100">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import { PRlist } from "../../api/login"
export default {
    mounted() {
        this.queryData()
    },
    data() {
        return {
            input1: null,
            input2: null,
            input3: null,
            //静态数据
            tableData: [],
            pageNum: 1,
            pageSize: 10,
        }
    },
    methods: {
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.pageSize = val;
            this.queryData()
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.pageNum = val;
            this.queryData()
        },
        // 查询
        queryData() {
            let data = {
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                relatedTo: this.input1,
                initiatingDepartment: this.input2,
                itemName: this.input3
            }
            PRlist(data).then(res => {
                console.log("res.data.items");
                console.log(res.data.items);
                this.tableData = res.data.items
            })
        },
        // 重置
        resetData() {
            this.pageNum = 1,
            this.pageSize = 10,
            this.input1 = null,
            this.input2 = null,
            this.input3 = null,
            this.queryData();
        },
    },
}
</script>

<style scoped>
.top {
    width: 100%;
    height: 60px;
    display: flex;
}

.top_one {
    width: 20%;
    height: 40px;
    display: flex;
    margin-top: 10px;
    margin-left: 850px;
}

.zzy {
    width: 100%;
    height: 50px;
    flex-shrink: 0;
    display: flex;
}

.zzy1 {
    width: 28%;
    height: 50px;
    line-height: 50px;
    display: flex;
}

.zzy2 {
    width: 30%;
    height: 50px;
    line-height: 50px;
    display: flex;
    margin-left: -80px;
}

.zzy3 {
    width: 28%;
    height: 50px;
    line-height: 50px;
    display: flex;
    margin-left: 10px;

}

.el-date-editor--daterange.el-input,
.el-date-editor--daterange.el-input__inner,
.el-date-editor--timerange.el-input,
.el-date-editor--timerange.el-input__inner {
    width: 280px;
}

.zzy4 {
    width: 14%;
    flex-shrink: 0;
    display: flex;
    line-height: 50px;

}

.zsy {
    width: 100%;
    height: 60px;
    display: flex;
}

.zsy1 {
    width: 100%;
    display: flex;
    justify-content: space-evenly;
    text-align: center;
}

.zsy3 {
    width: 100%;
    height: 40px;
    display: flex;
    font-size: 12px;
}
</style>
